package com.bolt.support.captcha.impl;

import com.bolt.common.utils.CacheUtil;
import com.bolt.support.captcha.CaptchaCacheService;

public class LocalCaptchaService implements CaptchaCacheService {
    @Override
    public void set(String key, String value, long expiresInSeconds) {

        CacheUtil.set(key, value, expiresInSeconds*60);
    }

    @Override
    public boolean exists(String key) {
        return CacheUtil.exists(key);
    }

    @Override
    public void delete(String key) {
        CacheUtil.delete(key);
    }

    @Override
    public String get(String key) {
        return CacheUtil.get(key);
    }

    @Override
    public Long increment(String key, long val) {
        Long ret = Long.valueOf(CacheUtil.get(key))+val;
        CacheUtil.set(key,ret+"",60);
        return ret;
    }

}